package iteratorPattern.demo;

import java.util.Iterator;

/**
 * @author： pang-yun
 * @date： 2021-12-09 20:08
 * 功能目的 ：用于
 */

public class ComputerCollege implements College {

    Department[] departments;
    // 保存当前数组的对象个数
    int numOfDepartment = 0;

    public ComputerCollege() {
        departments = new Department[5];
        addDepartment("A", "A");
        addDepartment("B", "B");
        addDepartment("C", "C");
        addDepartment("D", "D");
        addDepartment("E", "E");
    }

    @Override
    public String getName() {
        return "ComputerCollege";
    }

    @Override
    public void addDepartment(String name, String desc) {
        Department department = new Department(name, desc);
        departments[numOfDepartment]=department;
        numOfDepartment++;
    }

    @Override
    public Iterator createIterator() {
        return new ComputerCollegeIterator(departments);
    }
}
